﻿#ifndef PLAYER_H
#define PLAYER_H
#include <QMetaType>
#include <QObject>
#include "cards.h"
#include "card.h"
class Player : public QObject
{
    Q_OBJECT
public:
    enum Role{lord,farmer};
    enum Sex{Man,Woman};
    enum Direction{left,right};
    enum Type{Robot,User,Unknown};
    explicit Player(QObject *parent = nullptr);
    explicit Player(QString name, QObject *parent = nullptr);

    //名字
    void setName(QString name);
    QString getName();
    
    //角色
    void setRole(Role role);
    Role getRole();
    
    //性别
    void setSex(Sex sex);
    Sex getSex();
    
    //方位
    void setDirection(Direction dir);
    Direction getDirection();
    
    //玩家类型
    void setType(Type type);
    Type getType();
    
    //分数
    void setScore(int score);
    int getScore();
    
    //输赢
    void setWin(bool flag);
    bool getWin();

    //提供当前对象的上下家对象
    void setPrevPlayer(Player* palyer);
    void setNextPlayer(Player* player);
    Player* getPrevPlayer();
    Player* getNextPlayer();

    //叫地主
    void grabLordBet(int point);

    //存储扑克牌
    void storeDispatchCard(Cards& card);
    void storeDispatchCard(Card &card);

    //得到所有的牌
    Cards getCards();
    //清空所有的牌
    void clearCards();
    //出牌
    void playHand(Cards& cards);
    //设置出牌的玩家和刚刚出的牌
    void setPendingInfo(Player* player,Cards& cards);
    //获取出牌玩家
    Player* getPendPlayer();
    //获取出的牌
    Cards getPendCards();

    //存储出牌玩家和打出的牌
    void storePendingInfo(Player* palyer,Cards& cards);
    //虚函数
    virtual void prepareCallLord();
    virtual void preparePlayHand();
    virtual void thinkCallLord();
    virtual void thinkPlayhand();

signals:
    //通知已经叫地主下注
    void notifyGrabLordBet(Player* player,int point);
    //通知已经出牌
    void notifyPlayhand(Player* player,Cards cards);
    //通知底牌发牌
    void notifyPickCards(Player* player,Cards &cards);
protected:
    QString m_name;
    Role m_role;
    Sex m_sex;
    Direction m_dir;
    Type m_type;
    int m_score;
    bool m_iswin;
    Player* m_prevPlayer;
    Player* m_nextPlayer;
    Cards m_cards;
    Player* m_pendPlayer;
    Cards m_pendCards;
};

#endif // PLAYER_H
